﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<!-- 下拉框 -->
<link rel="stylesheet" href="static/ace/css/chosen.css" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta charset="utf-8" />
<title>国内港口管理</title>
<meta name="description" content="" />
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />

<link rel="stylesheet" href="static/ace/css/bootstrap.css" />
<link rel="stylesheet" href="static/ace/css/font-awesome.css" />

<!-- text fonts -->
<link rel="stylesheet" href="static/ace/css/ace-fonts.css" />
<!-- ace styles -->
<link rel="stylesheet" href="static/ace/css/ace.css"
	class="ace-main-stylesheet" id="main-ace-style" />
<script type="text/javascript" src="static/js/jquery-1.7.2.js" /></script>
<script type="text/javascript">
			$(top.hangge());
		</script>
<!--提示框-->
<script type="text/javascript" src="static/js/jquery.tips.js"></script>
</head>
<body class="no-skin">
	<div class="main-container" id="main-container">
		<div class="main-content">
			<div class="main-content-inner">
				<div class="page-content">
					<div class="row">
						<div class="col-xs-12">
							<form method="post" id="shipownerForm">
								<fieldset>
									<table style="margin-top: 5px;"
										class="table table-striped table-bordered table-hover">
										<tr>
											<td style="width:80px; text-align: right; padding-top: 13px;">快速检索码:</td>

											<td><input type="text" name="FAST_SEARCH_CODE" id="FAST_SEARCH_CODE" placeholder="这里输入快速检索码" title="快速检索码" maxlength="32" style="width: 98%;" /></td>

											<td style="width:80px; text-align: right; padding-top: 13px;">是否可用:</td>
											<td><select style="width:  98%;" name="ENABLE">
													<option value="">全部</option>
													<option value="1">是</option>
													<option value="0">否</option>
											</select></td>
									
											<td style="width:80px; text-align: right; padding-top: 13px;">港区名称:</td>
											<td><input type="text" name="HARBOR_NAME" id="HARBOR_NAME" placeholder="这里输入港区名称" title="港区名称" maxlength="32" style="width: 98%;" /></td>
											<td style="width:80px; text-align: right; padding-top: 13px;">港区英文名:</td>
											<td><input type="text" name="HARBOR_ENGLISH_NAME" id="HARBOR_ENGLISH_NAME" placeholder="这里输入港区英文名" title="港区英文名" maxlength="32" style="width: 98%;" /></td>
									   </tr>
									   <tr>
											<td style="width:80px; text-align: right; padding-top: 13px;">里程:</td>
											<td><input type="text" name="MILEAGE" id="MILEAGE" placeholder="这里输入里程" title="里程" maxlength="32" style="width:98%;" />KM</td>
											<td style="width:80px; text-align: right; padding-top: 13px;">关区代码:</td>
											<td><input type="text" name="CUSTOMS_CODE" id="CUSTOMS_CODE"  placeholder="这里输入关区代码" title="关区代码" maxlength="32" style="width: 98%;" /></td>
									   
											<td style="width:80px; text-align: right; padding-top: 13px;">港口:</td>
											<td><input type="text" name="PORT" id="PORT" placeholder="这里输入港口" title="港口" maxlength="32" style="width: 98%;" /></td>
											<td style="width:80px; text-align: right; padding-top: 13px;">简称:</td>
											<td><input type="text" name="ABBREVIATION" id="ABBREVIATION" placeholder="这里输入简称" title="简称" maxlength="32" style="width: 98%;" /></td>
											
										</tr>
										<tr>
											<td style="width:80px; text-align: right; padding-top: 13px;">港口所属公司:</td>
											<td><input type="text" name="PORT_COMPANY" id="PORT_COMPANY" placeholder="这里输入港口所属公司" title="港口所属公司" maxlength="32" style="width: 98%;" /></td>
												<td style="width:80px; text-align: right; padding-top: 13px;">口岸:</td>
											<td><input type="text" name="SHORE" id="SHORE"  placeholder="这里输入口岸" title="口岸" maxlength="32" style="width: 98%;" /></td>
										
											<td style="width:80px; text-align: right; padding-top: 13px;">EDI代码:</td>
											<td><input type="text" name="EDI_CODE" id="EDI_CODE" placeholder="这里输入EDI代码" title="EDI代码" maxlength="32" style="width: 98%;" /></td>
	                                        <td style="width:80px; text-align: right; padding-top: 13px;">细分口岸代码:</td>
											<td><input type="text" name="SUBDIVIDE_SHORE_CODE" id="SUBDIVIDE_SHORE_CODE" placeholder="这里输入细分口岸代码" title="细分口岸代码" maxlength="32" style="width: 98%;" /></td>
										</tr>
										
											<tr>
											<td style="text-align: left;" colspan="10">
											<a class="btn btn-xs btn-success"> 
											<i class="ace-icon fa fa-pencil-square-o bigger-120" onclick="add();">添加</i>
											</a></td>
										</tr>

										
									</table>
								</fieldset>
							</form>
							<form  method="post" id="shipoener">
								<fieldset>
									<table style="margin-top: 5px;"
										class="table table-striped table-bordered table-hover">
										<tr>
											<td style="width: 79px; text-align: right; padding-top: 13px;">港区名称：</td>
											<td><input type="text"  name="HARBOR_NAME"
												value="${pd.HARBOR_NAME }" maxlength="32" style="width: 98%;" /></td>
											<td style="width: 79px; text-align: right; padding-top: 13px;">港区英文名：</td>
											<td><input type="text"  name="HARBOR_ENGLISH_NAME"
												value="${pd.HARBOR_ENGLISH_NAME }" maxlength="32" style="width: 98%;" /></td>
											<td style="width: 79px; text-align: right; padding-top: 13px;">港口：</td>
											<td><input type="text"  name="PORT" value="${pd.PORT }" maxlength="32" style="width: 98%;" /></td>
											<td style="width: 79px; text-align: right; padding-top: 13px;">EDI代码：</td>
											<td><input type="text"  name="EDI_CODE" value="${pd.EDI_CODE }" maxlength="32" style="width: 98%;" /></td>
											<td
												style="width: 79px; text-align: right; padding-top: 13px;">关区代码：</td>
											<td><input type="text"  name="CUSTOMS_CODE" value="${pd.CUSTOMS_CODE }" maxlength="32" style="width: 98%;" /></td>
												<td style="width: 79px; text-align: right; padding-top: 13px;">检索码：</td>
											<td><input type="text"  name="FAST_SEARCH_CODE" value="${pd.FAST_SEARCH_CODE }" maxlength="32" style="width: 98%;" /></td>
											<td style="text-align: left;" colspan="10"><a
												class="btn btn-xs btn-success"> <i
													class="ace-icon fa fa-pencil-square-o bigger-120"
													onclick="serch();">查询</i>
											</a></td>
										</tr>
									</table>
								</fieldset>
							</form>
<div><input type="button" value="批量删除"  onclick="shan()" /></div>

		

					<table id="simple-table" class="table table-striped table-bordered table-hover" style="margin-top:5px;">
								<thead>
									<tr>
										<th class="center" style="width: 30px;"><label
											class="pos-rel"><input type="checkbox" class="ace"
												id="selectAll" /><span class="lbl"></span></label></th>
										<th class="center">港区名称</th>
										<th class="center">港区英文名</th>
										<th class="center">里程</th>
										<th class="center">港口</th>
										<th class="center">口岸</th>
										<th class="center">细分口岸代码</th>
										<th class="center">EDI代码</th>
										<th class="center">关区代码</th>
										<th class="center">简称</th>
										<th class="center">是否可用</th>
										<th class="center">检索码</th>
										<th class="center">港口所属公司</th>
										<th class="center">修改</th>
										<th class="center">删除</th>
									</tr>
								</thead>
								<c:forEach items="${list}" var="domestic">
								   <tr>

										<td class="center" style="width: 30px;"><label
											class="pos-rel"><input type="checkbox" class="s1" name="s1"
												value="${domestic.ID}" /><span class="lbl"></span></label></td>
										<td class="center">${domestic.HARBOR_NAME}</td>
										<td class='center'>${domestic.HARBOR_ENGLISH_NAME}</td>
										<td class="center">${domestic.MILEAGE}</td>
										<td class="center">${domestic.PORT}</td>
										<td class="center">${domestic.SHORE}</td>
										<td class="center">${domestic.SUBDIVIDE_SHORE_CODE}</td>
										<td class="center">${domestic.EDI_CODE}</td>
										<td class="center">${domestic.CUSTOMS_CODE}</td>
										<td class="center">${domestic.ABBREVIATION}</td>
										<td class="center"><c:if test="${domestic.ENABLE ==1}">
        		                                              是
        </c:if> <c:if test="${domestic.ENABLE ==0}">
        		                                               否
        </c:if></td>
										
										<td class="center">${domestic.FAST_SEARCH_CODE}</td>
										<td class="center">${domestic.PORT_COMPANY}</td>
										<td class="center">
											<div class="hidden-sm hidden-xs btn-group">
												<a class="btn btn-xs btn-success"
													onclick="edit('${domestic.ID}');"> <i
													class="ace-icon fa fa-pencil-square-o bigger-120">修改</i>
												</a>
											</div>
										</td>
										<td class="center">
											<div class="hidden-sm hidden-xs btn-group">
												<a class="btn btn-xs btn-success"
													onclick="delet('${domestic.ID}');"> <i
													class="ace-icon fa fa-trash-o bigger-120">删除</i>
												</a>
											</div>
										</td>
                                     </tr>
									</c:forEach>
								
							</table>



						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
$(document).ready(function(){
	$("#selectAll").click(function(){
		if(this.checked){
			$(".s1:checkbox,selectAll").prop("checked", true);
			
		}else{
			$(".s1:checkbox,selectAll").prop("checked", false);
			
		}
	
	})
	$(".s1").click(function() {
			var obj = $(".s1");
			var flag = true;
			obj.each(function() {
				if (!$(this).is(":checked")) {
					flag = false;
					return false;
				}
			});
			if (flag == true) {
				$("#selectAll").prop("checked", true);
			} else {
				$("#selectAll").prop("checked", false);
			}
	
	
})
$("#shan").click(function(){

	     
	var arr=document.getElementsByName("s1");
	
	for(i=0;i<arr.length;i++){
	if(arr[i].checked){
	var a = arr[i].value;
	alert(a)
	

	}

	}

	
})



})
</script>
<script type="text/javascript">
//新增
function add(){
	if($("#FAST_SEARCH_CODE").val()==""){
		$("#FAST_SEARCH_CODE").tips({
			side:3,
            msg:'请填写快速检索码',
            bg:'#AE81FF',
            time:2
        });
		$("#FAST_SEARCH_CODE").focus();
		$("#FAST_SEARCH_CODE").val('');
		$("#FAST_SEARCH_CODE").css("background-color","white");
		return false;
	}
	if($("#ENABLE").val()==""){
		$("#ENABLE").tips({
			side:3,
            msg:'请填写是否可用',
            bg:'#AE81FF',
            time:2
        });
		$("#ENABLE").focus();
		$("#ENABLE").val('');
		$("#ENABLE").css("background-color","white");
		return false;
	}
	if($("#HARBOR_NAME").val()==""){
		$("#HARBOR_NAME").tips({
			side:3,
            msg:'请填写港区名称',
            bg:'#AE81FF',
            time:2
        });
		$("#HARBOR_NAME").focus();
		$("#HARBOR_NAME").val('');
		$("#HARBOR_NAME").css("background-color","white");
		return false;
	}
	if($("#HARBOR_ENGLISH_NAME").val()==""){
		$("#HARBOR_ENGLISH_NAME").tips({
			side:3,
            msg:'请填写港区英文名',
            bg:'#AE81FF',
            time:2
        });
		$("#HARBOR_ENGLISH_NAME").focus();
		$("#HARBOR_ENGLISH_NAME").val('');
		$("#HARBOR_ENGLISH_NAME").css("background-color","white");
		return false;
	}
	
	if($("#MILEAGE").val()==""){
		$("#MILEAGE").val(0);
		}
		else if(isNaN(Number($("#MILEAGE").val()))){
		$("#MILEAGE").tips({
			side:3,
            msg:'请填写数字',
            bg:'#AE81FF',
            time:3
        });
		$("#MILEAGE").focus();
		$("#MILEAGE").val('');
		$("#MILEAGE").css("background-color","white");
		return false;
	}
	if($("#CUSTOMS_CODE").val()==""){
		$("#CUSTOMS_CODE").tips({
			side:3,
            msg:'请填写关区代码',
            bg:'#AE81FF',
            time:2
        });
		$("#CUSTOMS_CODE").focus();
		$("#CUSTOMS_CODE").val('');
		$("#CUSTOMS_CODE").css("background-color","white");
		return false;
	}
	if($("#PORT").val()==""){
		$("#PORT").tips({
			side:3,
            msg:'请填写港口',
            bg:'#AE81FF',
            time:2
        });
		$("#PORT").focus();
		$("#PORT").val('');
		$("#PORT").css("background-color","white");
		return false;
	}
	if($("#ABBREVIATION").val()==""){
		$("#ABBREVIATION").tips({
			side:3,
            msg:'请填写简称',
            bg:'#AE81FF',
            time:2
        });
		$("#ABBREVIATION").focus();
		$("#ABBREVIATION").val('');
		$("#ABBREVIATION").css("background-color","white");
		return false;
	}
	if($("#PORT_COMPANY").val()==""){
		$("#PORT_COMPANY").tips({
			side:3,
            msg:'请填写港口所属公司',
            bg:'#AE81FF',
            time:2
        });
		$("#PORT_COMPANY").focus();
		$("#PORT_COMPANY").val('');
		$("#PORT_COMPANY").css("background-color","white");
		return false;
	}
	if($("#SHORE").val()==""){
		$("#SHORE").tips({
			side:3,
            msg:'请填写口岸',
            bg:'#AE81FF',
            time:2
        });
		$("#SHORE").focus();
		$("#SHORE").val('');
		$("#SHORE").css("background-color","white");
		return false;
	}
	if($("#EDI_CODE").val()==""){
		$("#EDI_CODE").tips({
			side:3,
            msg:'请填写EDI代码',
            bg:'#AE81FF',
            time:2
        });
		$("#EDI_CODE").focus();
		$("#EDI_CODE").val('');
		$("#EDI_CODE").css("background-color","white");
		return false;
	}
	if($("#SUBDIVIDE_SHORE_CODE").val()==""){
		$("#SUBDIVIDE_SHORE_CODE").tips({
			side:3,
            msg:'请填写细分口岸代码',
            bg:'#AE81FF',
            time:2
        });
		$("#SUBDIVIDE_SHORE_CODE").focus();
		$("#SUBDIVIDE_SHORE_CODE").val('');
		$("#SUBDIVIDE_SHORE_CODE").css("background-color","white");
		return false;
	}
	 $.ajax({
         type: "POST",
         url: '<%=basePath%>domestic/adddomestic',
         data: $("#shipownerForm").serialize(),
         dataType: 'json',
         cache: false,
         success: function (data) {
        	 alert("保存成功")
        	 window.location.reload();
        	 
         }
     });
}

   //查詢
	function serch() {
		top.jzts();
		$("#shipoener").submit();
	}
	
   //修改
   function edit(ID){
	   top.jzts();
	    var diag = new top.Dialog();
	    diag.Drag = true;
	    diag.Title = "编辑";
	    diag.URL = '<%=basePath%>domestic/editdomestic?ID=' + ID;
	    diag.Width = 600;
	    diag.Height = 415;
	    diag.CancelEvent = function () { //关闭事件
	    	diag.close();
	  
	    	window.location.reload();	
	    };
	    diag.show();
	}
	   
 //删除
   function delet(ID){
  	
  	if (confirm("确认要删除本条信息！")){
  		$.ajax({
  			type:"post",
  			url:'<%=basePath%>domestic/deletedomestic?ID='+ID,
  			success:function(){
  				window.location.reload();
  			}
  			
  		})
  		return false;
  		}
  	
  	
  	
  }   
 //全删
function shan(){
var trList = [];
var $simpleTabletr = $("#simple-table tbody tr");
var list = {}
for(var i=0,len=$simpleTabletr.length;i<len;i++){
var objTr = $simpleTabletr[i];
var flag = $(objTr).find("td").first().find("label").find(".s1")[0].checked;

if(flag){
trList.push(objTr);
}
}
//传到后台的data json格式
var data = [];
for(var i=0,size=trList.length;i<size;i++){
var $tds = $(trList[i]).find("td");
//取id
var id = $($tds[0]).find("label").find("input[name='s1']")[0].value;
var item = {};
item.ID = id.trim();

data.push(item)
}
var dataStr = JSON.stringify(data);
if (confirm("确认要删除选中的信息！")){
$.ajax({
type: "POST",
url: '<%=basePath%>domestic/deleteInfo',
data: {dataJsonStr:dataStr},
cache: false,
success:function (data) {
	 window.location.reload();
	 
}
   });

return false;
}

}
	
</script>
</html>